package com.example.zhangxin.myhuatuob2b.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by ZhangXin on 2016/10/11.
 */

public class Home7Data {

    public static final String IMAGE = "image";
    public static final String GOODS_ID = "goods_id";
    public static final String GOODS_NAME = "goods_name";
    public static final String GOODS_PROMOTION_PRICE = "goods_promotion_price";//促销价格
    public static final String GOODS_IMAGE = "goods_image";
    public static final String GOODS_GUIGE = "drug_spec";         //商品规格
    public static final String GOODS_FACTORY = "product_company";
    private String image;
    private String goods_id;
    private String goods_name;
    private String goods_promotion_price;
    private String goods_image;
    private String goods_guige;
    private String goods_factory;

    public Home7Data(String image, String goods_id, String goods_name, String goods_promotion_price, String goods_image, String goods_guige, String goods_factory) {
        this.image = image;
        this.goods_id = goods_id;
        this.goods_name = goods_name;
        this.goods_promotion_price = goods_promotion_price;
        this.goods_image = goods_image;
        this.goods_guige = goods_guige;
        this.goods_factory = goods_factory;
    }

    public Home7Data() {

    }

    public static ArrayList<Home7Data> newInstanceList(String json){
        ArrayList<Home7Data> home7Datas = new ArrayList<>();
        try {
            JSONArray arr = new JSONArray(json);
            int size = null == arr ? 0 : arr.length();
            for (int i = 0; i < size; i++) {
                JSONObject jsonObject = arr.getJSONObject(i);
                String goods_id = jsonObject.optString(GOODS_ID);
                String name = jsonObject.optString(GOODS_NAME);
                String price = jsonObject.optString(GOODS_PROMOTION_PRICE);
                String image = jsonObject.optString(GOODS_IMAGE);
                String spec = jsonObject.optString(GOODS_GUIGE);
                String company = jsonObject.optString(GOODS_FACTORY);
                home7Datas.add(new Home7Data(image,goods_id,name,price,image,spec,company));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return home7Datas;
    }

    public String getImage() {

        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getGoods_id() {
        return goods_id;
    }

    public void setGoods_id(String goods_id) {
        this.goods_id = goods_id;
    }

    public String getGoods_name() {
        return goods_name;
    }

    public void setGoods_name(String goods_name) {
        this.goods_name = goods_name;
    }

    public String getGoods_promotion_price() {
        return goods_promotion_price;
    }

    public void setGoods_promotion_price(String goods_promotion_price) {
        this.goods_promotion_price = goods_promotion_price;
    }

    public String getGoods_image() {
        return goods_image;
    }

    public void setGoods_image(String goods_image) {
        this.goods_image = goods_image;
    }

    public String getGoods_guige() {
        return goods_guige;
    }

    public void setGoods_guige(String goods_guige) {
        this.goods_guige = goods_guige;
    }

    public String getGoods_factory() {
        return goods_factory;
    }

    public void setGoods_factory(String goods_factory) {
        this.goods_factory = goods_factory;
    }

}
